; Music of Olli and Lissa 3 - The Candlelight Adventure (1989) (Codemasters)
; Ripped by Megachur the 18/01/2007

	write "OLLIANL3.BIN"

music_date_rip	equ &1217
music_adr	equ &83c6
first_theme	equ 0
last_theme	equ 0

	read "music_header_v1_0.asm"
;
.play_music
;
	push hl
	push bc
	call l8439
	pop bc
	pop hl
	ret
;
.init_music
;
	ld a,#03
	ld (l8705),a
	ld (l8706),a
	ld a,#01
	ld (l8704),a
	ld hl,(l880a)
	ld ix,l86b3
	call l840c
	call l84c6
	ld hl,(l880c)
	ld ix,l86ce
	call l840c
	call l84c6
	ld hl,(l880e)
	ld ix,l86e9
	call l840c
	call l84c6
	xor a
	ld (l8704),a
	ld a,#38
	ld (l86af),a
	ret
.l840c
	ld (ix+#00),l
	ld (ix+#01),h
	ld (ix+#02),#00
	ld (ix+#03),#00
	ld (ix+#16),#00
	ld (ix+#12),#00
	ld (ix+#1a),#00
	ld (ix+#08),#00
	ld (ix+#09),#01
	ld hl,l8438
	ld (ix+#0a),l
	ld (ix+#0b),h
	ret
.l8438
	rst #38
.l8439
	ld a,(l8704)
	or a
	jr z,l8454
	ld hl,l86a8
	ld (hl),#00
	ld de,l86a9
	ld bc,#000a
	ldir
	ld a,#3f
	ld (l86af),a
	jp l84a0
.l8454
	ld hl,l8705
	dec (hl)
	jp nz,l8474
	ld a,(l8706)
	ld (hl),a
	ld ix,l86b3
	call l84c6
	ld ix,l86ce
	call l84c6
	ld ix,l86e9
	call l84c6
.l8474
	ld ix,l86b3
	call l85ec
	ld (l86a8),hl
	ld (l86b0),a
	ld ix,l86ce
	call l85ec
	ld (l86aa),hl
	ld (l86b1),a
	ld ix,l86e9
	call l85ec
	ld (l86ac),hl
	ld (l86b2),a
	ld a,#38
	ld (l86af),a
.l84a0
	ld hl,l86a8
	ld bc,#0b00
	ld de,#f480
.l84a9
	push bc
	push hl
	ld a,(hl)
	ld hl,#f600
	ld b,d
	out (c),c
	ld b,h
	out (c),d
	out (c),l
	ld b,d
	out (c),a
	ld b,h
	out (c),e
	out (c),l
	pop hl
	pop bc
	inc c
	inc hl
	djnz l84a9
	ret
.l84c6
	dec (ix+#09)
	ret nz
	ld (ix+#16),#00
	ld l,(ix+#0a)
	ld h,(ix+#0b)
	ld a,(hl)
	cp #ff
	jr nz,l851e
.l84d9
	ld l,(ix+#00)
	ld h,(ix+#01)
	ld e,(ix+#02)
	ld d,(ix+#03)
	add hl,de
	inc de
	ld a,(hl)
	cp #ff
	jr nz,l84f6
	ld de,#0001
	ld l,(ix+#00)
	ld h,(ix+#01)
	ld a,(hl)
.l84f6
	ld (ix+#02),e
	ld (ix+#03),d
	bit 7,a
	jr z,l850f
	and #7f
	cp #7e
	jr nz,l850a
	ld (l8704),a
	ret
.l850a
	ld (ix+#12),a
	jr l84d9
.l850f
	and #7f
	add a
	ld hl,l8820
	ld e,a
	ld d,#00
	add hl,de
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	ld a,(hl)
.l851e
	inc hl
	bit 5,a
	jr z,l8527
	set 1,(ix+#1a)
.l8527
	bit 7,a
	jr z,l8594
	and #1f
	inc a
	ld (ix+#09),a
	ld a,(hl)
	inc hl
	push hl
	add a
	ld e,a
	ld d,#00
	ld hl,l87c7
	add hl,de
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	ld a,(hl)
	and #7f
	add a
	ld e,a
	inc hl
	ld a,(hl)
	ld (ix+#06),a
	ld (ix+#07),a
	inc hl
	ld a,(hl)
	ld (ix+#18),a
	inc hl
	ld a,(hl)
	ld (ix+#17),a
	ld (ix+#19),a
	or a
	jr z,l8561
	set 7,(ix+#1a)
.l8561
	inc hl
	ld (ix+#04),l
	ld (ix+#05),h
	ld (ix+#13),l
	ld (ix+#14),h
	ld d,#00
	ld hl,l8802
	add hl,de
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	ld a,(hl)
	inc hl
	ld (ix+#10),a
	ld (ix+#11),a
	ld (ix+#0c),l
	ld (ix+#0d),h
	ld (ix+#0e),l
	ld (ix+#0f),h
	pop hl
	ld a,(hl)
	ld (ix+#15),a
	inc hl
	jr l85b3
.l8594
	bit 6,a
	jr z,l85a8
	and #1f
	inc a
	ld (ix+#09),a
	ld (ix+#15),#00
	ld (ix+#16),#01
	jr l85b3
.l85a8
	and #1f
	inc a
	ld (ix+#09),a
	ld a,(hl)
	ld (ix+#15),a
	inc hl
.l85b3
	ld (ix+#0a),l
	ld (ix+#0b),h
	set 6,(ix+#1a)
	bit 1,(ix+#1a)
	jr nz,l85e7
	ld a,(ix+#07)
	ld (ix+#06),a
	ld a,(ix+#11)
	ld (ix+#10),a
	ld l,(ix+#0e)
	ld h,(ix+#0f)
	ld (ix+#0c),l
	ld (ix+#0d),h
	ld l,(ix+#13)
	ld h,(ix+#14)
	ld (ix+#04),l
	ld (ix+#05),h
.l85e7
	res 1,(ix+#1a)
	ret
.l85ec
	ld l,(ix+#0c)
	ld h,(ix+#0d)
	ld a,(hl)
	dec (ix+#10)
	jr nz,l8612
	ld a,(ix+#11)
	ld (ix+#10),a
	inc hl
	ld a,(hl)
	cp #ff
	jr nz,l860c
	ld l,(ix+#0e)
	ld h,(ix+#0f)
	ld a,(hl)
	inc hl
.l860c
	ld (ix+#0c),l
	ld (ix+#0d),h
.l8612
	add (ix+#15)
	add (ix+#12)
	sub #0c
	jr nc,l861d
	xor a
.l861d
	and #7f
	ld hl,l8707
	add a
	ld e,a
	ld d,#00
	add hl,de
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	srl h
	rr l
	ld c,(ix+#1a)
	bit 7,c
	jr z,l867a
	ld b,(ix+#17)
	ld e,(ix+#19)
	ld a,e
	bit 6,c
	jr nz,l8645
	bit 0,c
	jr z,l8663
.l8645
	bit 5,c
	jr nz,l8655
	sub (ix+#18)
	jr nc,l8660
	set 5,(ix+#1a)
	xor a
	jr l8660
.l8655
	add (ix+#18)
	cp b
	jr c,l8660
	res 5,(ix+#1a)
	ld a,b
.l8660
	ld (ix+#19),a
.l8663
	srl b
	sub b
	ld c,a
	ld b,#00
	jr nc,l866c
	dec b
.l866c
	ld a,d
	add #a0
	jr nc,l8679
.l8671
	rlc c
	rr b
	add #18
	jr nc,l8671
.l8679
	add hl,bc
.l867a
	ld a,(ix+#1a)
	xor #01
	ld (ix+#1a),a
	xor a
	cp (ix+#16)
	ret nz
	ld e,(ix+#04)
	ld d,(ix+#05)
	dec (ix+#06)
	jr nz,l86a6
	ld a,(ix+#07)
	ld (ix+#06),a
	inc de
	ld a,(de)
	cp #ff
	jr z,l86a5
	ld (ix+#04),e
	ld (ix+#05),d
	inc de
.l86a5
	dec de
.l86a6
	ld a,(de)
	ret
.l86af equ $ + 7
.l86ac equ $ + 4
.l86aa equ $ + 2
.l86a9 equ $ + 1
.l86a8
	db #00,#00,#00,#00,#00,#00,#00,#00
.l86b3 equ $ + 3
.l86b2 equ $ + 2
.l86b1 equ $ + 1
.l86b0
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
.l86ce equ $ + 6
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
.l86e9 equ $ + 1
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00
.l8706 equ $ + 2
.l8705 equ $ + 1
.l8704
	db #00,#00,#00
.l8707
	dw #0eee,#0e17,#0d4d,#0c8e
	dw #0bd9,#0b2f,#0a8e,#09f7
	dw #0967,#08e0,#0861,#07e8
	dw #0777,#070b,#06a6,#0647
	dw #05ec,#0597,#0547,#04fb
	dw #04b3,#0470,#0430,#03f4
	dw #03bb,#0385,#0353,#0323
	dw #02f6,#02cb,#02a3,#027d
	dw #0259,#0238,#0218,#01fa
	dw #01dd,#01c2,#01a9,#0191
	dw #017b,#0165,#0151,#013e
	dw #012c,#011c,#010c,#00fd
	dw #00ee,#00e1,#00d4,#00c8
	dw #00bd,#00b2,#00a8,#009f
	dw #0096,#008e,#0086,#007e
	dw #0077,#0070,#006a,#0064
	dw #005e,#0059,#0054,#004f
	dw #004b,#0047,#0043,#003f
	dw #003b,#0038,#0035,#0032
	dw #002f,#002c,#002a,#0027
	dw #0025,#0023,#0021,#001f
	dw #001d,#001c,#001a,#0019
	dw #0017,#0016,#0015,#0013
	dw #0012,#0011,#0010,#000f
.l87c7
	dw l87cf,l87d9,l87ea,l87f8
.l87cf
	db #00,#02,#06,#03,#0f,#0e,#0d,#0c
.l87d9 equ $ + 2
	db #0a,#ff,#00,#02,#0c,#05,#0d,#0b
	db #0a,#09,#08,#07,#06,#05,#04,#03
.l87ea equ $ + 3
	db #02,#01,#ff,#00,#01,#02,#04,#0e
	db #0d,#0c,#0b,#0a,#09,#04,#01,#00
.l87f8 equ $ + 1
	db #ff,#00,#02,#00,#00,#0f,#0f,#0d
.l8802 equ $ + 3
	db #0b,#09,#ff,#04,#88,#01,#00,#00
	db #00,#00,#ff
.l880a
	dw l8810
.l880c
	dw l881a
.l880e
	dw l8814
.l8814 equ $ + 4
.l8810
	db #80,#00,#03,#ff,#8c,#01,#01,#01
.l881a equ $ + 2
	db #01,#ff,#80,#02,#02,#02,#02,#ff
.l8820
	dw l8828,l891f,l8931,l88a5
.l8828
	db #87,#00,#24,#07,#24,#03,#26,#03
	db #24,#03,#26,#03,#24,#07,#29,#07
	db #29,#03,#2b,#03,#29,#03,#2b,#03
	db #29,#07,#24,#07,#24,#01,#32,#01
	db #32,#41,#01,#32,#01,#32,#41,#03
	db #32,#01,#30,#01,#30,#41,#01,#30
	db #01,#30,#41,#03,#30,#01,#24,#03
	db #24,#41,#07,#24,#01,#24,#01,#26
	db #41,#01,#26,#01,#28,#41,#01,#28
	db #01,#29,#41,#01,#2b,#01,#2d,#41
	db #03,#2d,#03,#2f,#0f,#30,#07,#35
	db #07,#29,#01,#28,#03,#2b,#41,#07
	db #24,#07,#32,#07,#26,#01,#29,#03
	db #2e,#41,#07,#29,#01,#24,#01,#26
	db #01,#28,#01,#29,#01,#2b,#01,#2d
.l88a5 equ $ + 5
	db #01,#2f,#01,#30,#ff,#87,#03,#24
	db #07,#24,#03,#26,#03,#24,#03,#26
	db #03,#24,#07,#29,#07,#29,#03,#2b
	db #03,#29,#03,#2b,#03,#29,#03,#28
	db #43,#07,#28,#03,#2b,#43,#07,#2b
	db #01,#2e,#01,#2e,#41,#01,#2e,#01
	db #2e,#41,#03,#2e,#0f,#2d,#0f,#2b
	db #0f,#2b,#0f,#29,#0f,#29,#01,#26
	db #01,#24,#01,#26,#01,#24,#01,#29
	db #01,#24,#01,#2b,#01,#24,#01,#2d
	db #01,#2b,#01,#2f,#01,#2b,#01,#30
	db #01,#2b,#01,#32,#01,#2b,#01,#24
	db #01,#22,#01,#26,#01,#22,#01,#28
	db #01,#22,#01,#29,#01,#22,#01,#2b
	db #01,#29,#01,#2b,#01,#29,#01,#2c
.l891f equ $ + 7
	db #01,#29,#01,#2d,#01,#29,#ff,#87
	db #01,#0c,#07,#18,#07,#13,#07,#1f
	db #07,#16,#07,#22,#07,#11,#07,#1d
.l8931 equ $ + 1
	db #ff,#81,#02,#18,#01,#1c,#01,#1f
	db #01,#24,#01,#28,#01,#2b,#01,#28
	db #01,#24,#01,#1f,#01,#23,#01,#26
	db #01,#2b,#01,#2f,#01,#32,#01,#2f
	db #01,#2b,#01,#16,#01,#1a,#01,#1d
	db #01,#22,#01,#26,#01,#29,#01,#26
	db #01,#22,#01,#29,#01,#2d,#01,#30
	db #01,#35,#01,#39,#01,#3c,#01,#39
	db #01,#35,#ff

.game_name
	db "Olli and Lissa 3 - The Candlelight Adventure",0
.game_year
	db "1989",0
.game_publisher
	db "Codemasters",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
